var mysql = require("mysql");
var pool = mysql.createPool({
    host: 'localhost',
    user: 'root',
    password: '123456',
    database: 'mydb'
});
var query = function (sql, callback) {
    pool.getConnection(function (err, conn) {
        if (err) {
            callback(err, null, null);
        } else {
            conn.query(sql, function (err, result) {
                conn.release();// 释放连接资源
                callback(err, result);//事件驱动回调
            });
        }
    });
};
module.exports = query;